<?php
/**
 * $Id: view.html.php 7 2010-04-26 20:05:00Z webbochsant $
 *  @package	Joomla
 *  @author Daniel Eliasson
* 	@copyright	Copyright (C) 2010 Stilero. All rights reserved.
* 	@license	GNU/GPL, see LICENSE.php
* 	Joomla! is free software. This version may have been modified pursuant
* 	to the GNU General Public License, and as distributed it includes or
* 	is derivative of works licensed under the GNU General Public License or
* 	other free or open source software licenses.
*/

// no direct access
defined('_JEXEC') or die('Restricted access'); 

jimport( 'joomla.application.component.view' );

/**
 * Hello View
 *
 * @package    Joomla.Tutorials
 * @subpackage Components
 */
class VmcompetitionsViewContestant extends JView
{
	/**
	 * display method of Hello view
	 * @return void
	 **/
	function display($tpl = null)
	{
		//get the hello
		$contestant		=& $this->get('Data');
		$isNew		= ($contestant->cid < 1);
		$text = $isNew ? JText::_( 'New' ) : JText::_( 'Edit' );
		JToolBarHelper::title(   JText::_( 'Contestant' ).': <small><small>[ ' . $text.' ]</small></small>' );
		JToolBarHelper::save();
		if ($isNew)  {
			JToolBarHelper::cancel();
		} else {
			// for existing items the button is renamed `close`
			JToolBarHelper::cancel( 'cancel', 'Close' );
		}
		// published
		
		
		$this->assignRef('contestant',		$contestant);
		
		$db		=& JFactory::getDBO();
	    
	    // Build Product select list
		$sql = 'SELECT id, title'
		. ' FROM #__vm_competition'
		. ' ORDER BY publish_up DESC'
		;
		$db->setQuery($sql);
		if (!$db->query())
		{
			$this->setRedirect( 'index.php?option=com_vmcompetition' );
			return JError::raiseWarning( 500, $db->getErrorMsg() );
		}

		$complist[]		= JHTML::_('select.option',  '0', JText::_( 'Select Competition' ), 'id', 'title' );
		$this->complist			= array_merge( $complist, $db->loadObjectList() );
		//$this->lists['pid']		= JHTML::_('select.genericlist',   $productlist, 'pid', 'class="inputbox" size="1"','product_id', 'product_name', $row->product_id );

		parent::display($tpl);
	}
}

?>